home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / lnklst10.zip / LINKLIST.H < prev    next >
C/C++ Source or Header  |  1993-01-19  |  2KB  |  53 lines

  1. /*
  2.  *
  3.  * LINKLIST.H: Typedefs and #defines for Linked list functions and
  4.  * macros.
  5.  *
  6.  * All code is (c) Copyright 1993 Ben Morris and SpeedSOFT Development.
  7.  * Ben Morris Retains all intellectual rights and copyrights to this
  8.  * code.  Under no circumstances is the author's name to be removed from
  9.  * the header file, source file or object code created by compiling the
  10.  * source code.
  11.  *
  12.  * Other than the above restriction, this code may be used freely with
  13.  * any software, commercial or otherwise.
  14.  *
  15.  * Ben Morris also disclaims all warranties, express or implied, with
  16.  * regards to the fitness of this code for any purpose.  Under no
  17.  * circumstances shall Ben Morris or SpeedSOFT Development be held liable
  18.  * for any damages, losses, or claim for loss of profit, resulting from
  19.  * the use or inability to use this software and all accompanying
  20.  * documentation.
  21.  *
  22.  */
  23.  
  24. #ifndef LINKLIST__H
  25. #define LINKLIST__H
  26.  
  27. #include <stdio.h>
  28. #include <stdlib.h>
  29. #include <dos.h>
  30.  
  31. typedef struct node_struc
  32. {
  33.     struct  node_struc  *prev;
  34.     struct  node_struc  *next;
  35.     void    *data;
  36.  
  37. } NODE, *NODEPTR;
  38.  
  39. #define NodePrev(ndp)   ((NODEPTR)((ndp)->prev))
  40. #define NodeNext(ndp)   ((NODEPTR)((ndp)->next))
  41. #define NodeFirst(hndp) ((NODEPTR)((hndp)->next))
  42. #define NodeLast(hndp)  ((NODEPTR)((hndp)->prev))
  43. #define NodeTotal(hndp) (NodePtrtoNum((hndp)->prev, (hndp)))
  44.  
  45. NODEPTR InitList( void );
  46. NODEPTR NodeInsert( NODEPTR prev_ndp, size_t size );
  47. void    NodeDelete( NODEPTR ndp );
  48. NODEPTR NodeNumtoPtr( int num, NODEPTR head_ndp );
  49. int     NodePtrtoNum( NODEPTR sndp, NODEPTR head_ndp );
  50. void    DestroyList( NODEPTR head_ndp );
  51.  
  52. #endif /* LINKLIST__H */
  53.